﻿using System;
using System.Collections.Generic;
using System.Drawing;

namespace Games.Classes
{
	public enum BoardType
	{
		Plain,
		Garden,
		Dessert,
		Snow
	}

	public class Board
	{
		public string Name { get; set; }
		public Color BackGroundColor { get; set; }
		public Color TextColor { get; set; }
		public Color BarrierColor { get; set; }
		public Color SnakeHeadColor { get; set; }
		public Color SnakeBodyColor { get; set; }
		public Color FoodColor { get; set; }


		public List<DrawingItem> Barriers { get; set; }

		public Board(int difficulty, int width, int height)
		{
			Barriers = new List<DrawingItem>();
			var random = new Random();
			for (var i = 0; i < difficulty*10; i++)
			{
				Barriers.Add(new DrawingItem(random.Next(0, width / 16), random.Next(0, height / 16)));
			}
		}
	}

	public static class BoardFactory
	{
		public static Board GetBoard(int difficulty, int width, int height)
		{
			if (difficulty <= 5)
			{
				return GetBoard(BoardType.Garden, difficulty, width, height);
			}
			if (difficulty > 5 && difficulty <= 10)
			{
				return GetBoard(BoardType.Dessert, difficulty, width, height);
			}
			if (difficulty > 10 && difficulty <= 14)
			{
				return GetBoard(BoardType.Snow, difficulty, width, height);
			}
			return GetBoard(BoardType.Plain, difficulty, width, height);
		}

		public static Board GetBoard(BoardType type, int difficulty, int width, int height)
		{
			var board = new Board(difficulty, width, height)
				{
					BackGroundColor = Color.Black,
					BarrierColor = Color.Purple,
					FoodColor = Color.Orange,
					SnakeHeadColor = Color.DarkGreen,
					SnakeBodyColor = Color.LawnGreen,
					TextColor = Color.White,
					Name = "Space"
				};
			switch (type)
			{
					case BoardType.Garden:
					board.BackGroundColor = Color.DarkGreen;
					board.BarrierColor = Color.LawnGreen;
					board.FoodColor = Color.Orange;
					board.SnakeHeadColor = Color.Black;
					board.SnakeBodyColor = Color.SlateGray;
					board.TextColor = Color.White;
					board.Name = "Garden";
					break;
					case BoardType.Dessert:
					board.BackGroundColor = Color.Tan;
					board.BarrierColor = Color.SaddleBrown;
					board.FoodColor = Color.Blue;
					board.TextColor = Color.Black;
					board.Name = "Dessert";
					break;
					case BoardType.Snow:
					board.BackGroundColor = Color.White;
					board.BarrierColor = Color.Aqua;
					board.FoodColor = Color.Orange;
					board.SnakeHeadColor = Color.DarkGreen;
					board.SnakeBodyColor = Color.LawnGreen;
					board.TextColor = Color.Black;
					board.Name = "Snow";
					break;
			}
			return board;
		}
	}
}
